home *** CD-ROM | disk | FTP | other *** search
- public class ClassWander extends Codex {
- private static final int TIMER_ID_WANDER = 0;
- private static final int THINK_TIME = 2;
- private static final int RESTART_BUFFER = 10;
- private CodexActor _wanderThing = new CodexActor(((Codex)this).GetClassThing());
- private float _minSearch;
- private float _maxSearch;
- private float _minDelay;
- private float _maxDelay;
- private float _speed;
- private float _stepHeight;
- private float[] pos = new float[3];
- public static String[] _params = new String[]{"Min search radius;64", "Max search radius;320", "Min delay;2", "Max delay; 10", "Speed;210", "Step height to try; 16"};
-
- public void beginscene(int clientGuid, int captureID) {
- this.SendThing();
- }
-
- public void arrived(int thingGuid, int frameNum, int captureID) {
- ((Codex)this).SetTimer((float)((double)this._minDelay + Math.random() * (double)(this._maxDelay - this._minDelay)), 0);
- }
-
- public void SendThing() {
- boolean bSuccess = false;
- this.pos = this._wanderThing.GetPosition();
- this.pos[0] += (float)(((double)this._minSearch + Math.random() * (double)(this._maxSearch - this._minSearch)) * (double)(Math.random() < (double)0.5F ? -1 : 1));
- this.pos[1] += (float)(((double)this._minSearch + Math.random() * (double)(this._maxSearch - this._minSearch)) * (double)(Math.random() < (double)0.5F ? -1 : 1));
-
- while(!bSuccess) {
- if (this._wanderThing.SendActorToPos(this.pos, this._speed)) {
- bSuccess = true;
- ((Codex)this).SetTimer(this._maxDelay + 10.0F, 0);
- } else {
- this.pos[2] += this._stepHeight;
- if (!this._wanderThing.SendActorToPos(this.pos, this._speed)) {
- ((Codex)this).SetTimer(2.0F, 0);
- break;
- }
-
- bSuccess = true;
- ((Codex)this).SetTimer(this._maxDelay + 10.0F, 0);
- }
- }
-
- }
-
- public ClassWander(float minSearch, float maxSearch, float minDelay, float maxDelay, float speed, float stepHeight) {
- this._minSearch = minSearch;
- this._maxSearch = maxSearch;
- this._minDelay = minDelay;
- this._maxDelay = maxDelay;
- this._speed = speed;
- this._stepHeight = stepHeight;
- }
-
- public void timer(int timerID, float arg0, float arg1, float arg2, float arg3) {
- switch (timerID) {
- case 0:
- ((Codex)this).KillAllTimers();
- this._wanderThing.Stop();
- this.SendThing();
- default:
- }
- }
- }
-